<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
</head>

<body>
  <!-- 2.挂载点 -->
  <div id="app">
    <h3 v-html="msg"></h3>
    <input type="text" oninput="inputFn(this)">
  </div>

  <script>
    let data = {
      msg: '你好 mvvm'
    }
    // 代理对象
    let proxyData = {}
    Object.defineProperty(proxyData, 'msg', {
      get() {
        return data.msg
      },
      set(v) {
        if (v != data.msg) {
          // 修改源数据
          data.msg = v
          // 通过视图更新
          document.querySelector('[v-html]').innerHTML = v
        }
      }
    })

    function inputFn(node) {
      proxyData.msg = node.value
    }

    document.querySelector('[v-html]').innerHTML = proxyData.msg



  </script>

</body>

</html>